from stitching import Stitcher
import cv2
stitcher = Stitcher()


import os
import cv2


def cv2_read_images(image_path,*args,**kwagrs):
    return cv2.imread(image_path,*args,**kwagrs)
def read_images_in_folder(folder_path):
    images = []
    for filename in os.listdir(folder_path):
        # 确保文件是图像文件
        if filename.endswith('.jpg') or filename.endswith('.jpeg') or filename.endswith('.png'):
            # 读取图像
            image_path = os.path.join(folder_path, filename)
            image=cv2_read_images(image_path)
            if image is not None:
                images.append(image_path)
    return images



panorama = stitcher.stitch(read_images_in_folder('./data'))
print(type(panorama),panorama)
# cv2.imwrite('output_image.jpg', panorama)
# 保存图像

cv2.imwrite('output_image.jpg', panorama)

# 显示图像（可选）
cv2.imshow('Image', panorama)
cv2.waitKey(0)
cv2.destroyAllWindows()